home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / program / oxcc1434.zip / SRC / OXBYTES.H < prev    next >
C/C++ Source or Header  |  1996-09-03  |  8KB  |  318 lines

  1. /* 
  2.     oxbytes.h -- v1.430 definition of bytecodes for oxbow interpreter `bterp'
  3.  
  4.     Copyright (c) 1995
  5.     Norman D. Culver dba
  6.     Oxbow Software
  7.     1323 S.E. 17th Street #662
  8.     Ft. Lauderdale, FL 33316
  9.     (954) 463-4754
  10.     ndc@icanect.net
  11.     All rights reserved.
  12.  
  13.  * Redistribution and use in source and binary forms are permitted
  14.  * provided that: (1) source distributions retain this entire copyright
  15.  * notice and comment, and (2) distributions including binaries display
  16.  * the following acknowledgement:  ``This product includes software
  17.  * developed by Norman D. Culver dba Oxbow Software''
  18.  * in the documentation or other materials provided with the distribution
  19.  * and in all advertising materials mentioning features or use of this
  20.  * software.
  21.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  22.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  23.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  24.  
  25. */
  26.  
  27. #if NEED_BYTECODES
  28.  
  29. #if SUPPORT_LONG_DOUBLE
  30. #define XSZ (sizeof(long double))
  31. #else
  32. #define XSZ (sizeof(double))
  33. #endif
  34.  
  35.  
  36. #define A1 (0<<2)
  37. #define A2 (1<<2)
  38. #define A3 (2<<2)
  39. #define A4 (3<<2)
  40.  
  41. #define S1 (0<<2)
  42. #define S2 (1<<2)
  43. #define S3 (2<<2)
  44. #define S4 (3<<2)
  45.  
  46. #define D1 (0)
  47. #define D2 (1)
  48. #define D3 (2)
  49. #define D4 (3)
  50.  
  51. #define B1 (0)
  52. #define B2 (1)
  53. #define B4 (2)
  54. #define B8 (3)
  55. #define BX (4)
  56.  
  57. #define J1 (0)
  58. #define J2 (1)
  59. #define J3 (2)
  60. #define J4 (3)
  61.  
  62. #define BYTE    (0)
  63. #define SHORT    (1)
  64. #define LONG    (2)
  65. #define UBYTE    (3)
  66. #define USHORT    (4)
  67. #define ULONG    (5)
  68. #define FLOAT    (6)
  69. #define DOUBLE    (7)
  70.  
  71. #define SLONGLONG (6)
  72. #define SULONGLONG (7)
  73.  
  74. #define CLONGLONG    (8)
  75. #define CULONGLONG    (9)
  76. #define CLONGDOUBLE (10)    
  77.  
  78. #define LONGLONG    (0)
  79. #define ULONGLONG    (1)
  80. #define LONGDOUBLE    (2)
  81.  
  82. #define LS        (0x00)
  83. #define UNUSED1    (LS|A4)
  84. #define NEG        (0x10)
  85. #define MOVSS    (NEG|12)
  86. #define LM        (0x20)
  87. #define COMP    (0x30)
  88. #define JMP        (0x34)
  89. #define NOT        (0x38)
  90. #define SS        (0x40)
  91. #define UNUSED2    (SS|A4)
  92. #define TRUTHOF    (0x50)
  93. #define LI        (0x58)
  94. #define LUI        (0x5C)
  95. #define LAI        (0x60)
  96. #define SM        (0x70)
  97.  
  98. #define ADD        (0x80|(0<<3))
  99. #define SUB        (0x80|(1<<3))
  100. #define MUL        (0x80|(2<<3))
  101. #define DIV        (0x80|(3<<3))
  102. #define OR        (0x80|(4<<3))
  103. #define JMPT    (OR|4)
  104. #define AND        (0x80|(5<<3))
  105. #define JMPF    (AND|4)
  106. #define MOD        (0x80|(6<<3))
  107. #define MOVAAX    (MOD|6)
  108. #define XTD        (MOD|7)
  109. #define XOR        (0x80|(7<<3))
  110. #define MOVSM    (XOR|4)
  111. #define GT        (0x80|(8<<3))
  112. #define LT        (0x80|(9<<3))
  113. #define GE        (0x80|(10<<3))
  114. #define LE        (0x80|(11<<3))
  115. #define NE        (0x80|(12<<3))
  116. #define EQ        (0x80|(13<<3))
  117. #define ARG        (0x80|(14<<3))
  118. #define ARGA    (ARG|1)
  119. #define ARGF    (ARG|2)
  120. #define SWAP4DEEP    (ARG|3)
  121. #define LOCATE    (ARG|4)
  122. #define MOVMS    (0x80|(15<<3))
  123. #define MOVMM    (MOVMS|4)
  124.  
  125.  
  126. /* Immediate subgroup */
  127. #define SMI        (1<<4)
  128. #define SSI        (2<<4)
  129. #define MODI    (3<<4)
  130. #define DEREF    (4<<4)
  131. #define DEREF1    (5<<4)
  132.  
  133. /* Miscellaneous */
  134. #define DUMP    (NOT|4)
  135. #define CALL    (NOT|5)
  136. #define SWAP    (NOT|6)
  137. #define DUP        (NOT|7)
  138. #define LINENO    (TRUTHOF|0)
  139. #define CVT        (TRUTHOF|4)
  140. #define ABSSTK    (TRUTHOF|5)
  141. #define IMMED    (TRUTHOF|6)
  142. #define RET        (TRUTHOF|7)
  143. #define DUP4     (NEG|8)
  144. #define SWAP4     (NEG|9)
  145. #define MOVDA1    (NEG|10)
  146. #define MOVDA2    (NEG|11)
  147. #define MOVDA4    (LAI|4)
  148. #define MOVDA8    (LAI|5)
  149. #define MOVDAX    (LAI|6)
  150. #define MOVAA1    (LAI|7)
  151. #define LJMPT    (LAI|8)
  152. #define LJMPF    (LAI|12)
  153. #define NFUNC    (UNUSED1|0)
  154. #define NOP        (UNUSED1|1)
  155. #define MOVAAC    (UNUSED1|2)
  156. #define ABSMEM    (UNUSED1|3)
  157. #define MOVAA8    (UNUSED2|0)
  158. #define REGAIN    (UNUSED2|1)
  159. #define MOVAA2    (UNUSED2|2)
  160. #define MOVAA4    (UNUSED2|3)
  161.  
  162. /* extended subgroup */
  163. #define GETBITFIELD (LM|A4|1)
  164. #define PUTBITFIELD (LM|A4|2)
  165. #define CALLSETUP    (LM|A4|3)
  166. #define SWITCH        (SM|A4|1)
  167. #define PRUNESTRUCT (SM|A4|2)
  168. #define CLRDAT        (SM|A4|3)
  169. #define RETSTRUCT    (SM|A3|1)
  170. #define BUILTIN        (SM|A3|2)
  171. #define LSHI        (NEG|4)
  172. #define LSH            (NEG|8)
  173. #define RSH            (LAI)
  174. #define RSHI        (LAI|8)
  175.  
  176.  
  177. /* Interpreter builtins */
  178. #define ALLOCA 1
  179. #define SETJMP 2
  180. #define LONGJMP 3
  181. #define STRLEN 4
  182. #define STRCPY 5
  183. #define STRCAT 6
  184. #define MEMCPY 7
  185. #define MEMMOVE 8
  186. #define MEMSET 9
  187. #define BZERO 10
  188. #define MALLOC 11
  189. #define CALLOC 12
  190. #define REALLOC 13
  191. #define EXIT 14
  192. #define ABORT 15
  193. #define DEBUG 16
  194. #define NODEBUG 17
  195. #endif /* NEED_BYTECODES */
  196.  
  197. #if NEED_SPELLING
  198.  
  199. static char *Jbuf[] = {
  200. "J1","J2","J3","J4"
  201. };
  202. static int Jcnt[] = {
  203. 1,2,3,4
  204. };
  205. static char *Dbuf[] = {
  206. "D1","D2","D3","D4"
  207. };
  208. static int Dcnt[] = {
  209. 1,2,3,4
  210. };
  211. static char *SDbuf[] = {
  212. " S1|D1", " S1|D2", " S1|D3"," S1|D4",
  213. " S2|D1", " S2|D2", " S2|D3"," S2|D4",
  214. " S3|D1", " S3|D2", " S3|D3"," S3|D4",
  215. " S4|D1", " S4|D2", " S4|D3"," S4|D4"
  216. };
  217. static int SDcnt[] = {
  218. 2,3,4,5,3,4,5,6,4,5,6,7,5,6,7,8
  219. };
  220. static char *ABbuf[] = {
  221. "A1|B1","A1|B2","A1|B4","A1|B8",
  222. "A2|B1","A2|B2","A2|B4","A2|B8",
  223. "A3|B1","A3|B2","A3|B4","A3|B8",
  224. "A4|B1","A4|B2","A4|B4","A4|B8"
  225. };
  226. static int ABcnt[] = {
  227. 2,3,5,9,3,4,6,10,4,5,9,11,5,6,8,16
  228. };
  229. static char *Abuf[] = {
  230. "A1","A2","A3","A4"
  231. };
  232. static int Acnt[] = {
  233. 1,2,3,4
  234. };
  235. static char *Bbuf[] = {
  236. "B1","B2","B4","B8","BX"
  237. };
  238. static int Bcnt[] = {
  239. 1,2,4,8
  240. };
  241. static char *Tbuf[] = {
  242. "BYTE","SHORT","LONG","UBYTE","USHORT","ULONG","FLOAT","DOUBLE",
  243. "LONGLONG","ULONGLONG","LONGDOUBLE"
  244. };
  245. static char *XTbuf[] = {
  246. "LONGLONG","ULONGLONG","LONGDOUBLE","","","","LONGLONG","ULONGLONG"
  247. };
  248. static char *BUbuf[] = {"",
  249. "alloca ","setjmp ","longjmp ","strlen ","strcpy ","strcat ",
  250. "memcpy ","memmove ","memset ","bzero ","malloc ","calloc ",
  251. "realloc ","exit ","abort ","bterpdebug ", "bterpnodebug "
  252. };
  253.  
  254. #endif /* NEED_SPELLING */
  255.  
  256. #if NEED_AOUT_FORMAT
  257.  
  258. /* OUTPUT FORMAT IS A VARIANT OF A.OUT */
  259.  
  260. struct exec
  261. {
  262.   unsigned long a_info;         /* Contains MAGIC number */
  263.   unsigned a_text;              /* length of text, in bytes */
  264.   unsigned a_data;              /* length of data, in bytes */
  265.   unsigned a_bss;               /* length of uninitialized data area for file, in bytes */
  266.   unsigned a_syms;              /* length of symbol table data in file, in bytes */
  267.   unsigned a_entry;             /* start address */
  268.   unsigned a_trsize;            /* length of relocation info for text, in bytes */
  269.   unsigned a_drsize;            /* length of relocation info for data, in bytes */
  270. };
  271.  
  272. #define OMAGIC 0407
  273. #define NMAGIC 0410
  274. #define ZMAGIC 0413
  275.  
  276. /* a.out symbol table struct */
  277. struct nlist {
  278.   union {
  279.     char *n_name;
  280.     struct nlist *n_next;
  281.     long n_strx;
  282.   } n_un;
  283.   unsigned char n_type;
  284.   char n_other;
  285.   short n_desc;
  286.   unsigned long n_value;
  287. };
  288. #define N_UNDF 0x00
  289. #define N_ABS 0x02
  290. #define N_TEXT 0x04
  291. #define N_DATA 0x06
  292. #define N_BSS 0x08
  293. #define N_NDC 0x10
  294. #define N_COMM 0x12
  295. #define N_FN 0x0f
  296. #define N_EXT 0x01
  297. #define N_TYPE 0x1e
  298. #define N_STAB 0xe0
  299. #define N_INDR 0x0a                /* Symbol is indirect */
  300. #define N_SETA  0x14            /* Absolute set element symbol */
  301. #define N_SETT  0x16            /* Text set element symbol */
  302. #define N_SETD  0x18            /* Data set element symbol */
  303. #define N_SETB  0x1A            /* Bss set element symbol */
  304. #define N_SETV  0x1C            /* Pointer to set vector in data area.  */
  305. #define N_SWTAB 0x20            /* A switch table entry */
  306.  
  307. struct relocation_info
  308. {
  309.   long r_address;
  310.   unsigned long r_symbolnum:24;
  311.   unsigned long r_pcrel:1;
  312.   unsigned long r_length:2;
  313.   unsigned long r_extern:1;
  314.   unsigned long r_pad:4;
  315. };
  316.  
  317. #endif /* NEED_AOUT_FORMAT */
  318.